<!DOCTYPE html>

<html class="no-js">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title></title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <script src="https://cdn.staticfile.org/axios/0.19.0-beta.1/axios.js"></script>

  <script src="https://cdn.staticfile.org/vue/2.5.17/vue.js"></script>
  <!-- 导入表格需要的包 -->

  <script src="https://cdn.staticfile.org/FileSaver.js/2014-11-29/FileSaver.min.js"></script>
  <script src="https://cdn.staticfile.org/xlsx/0.14.1/xlsx.full.min.js"></script>
  <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.13.0/theme-chalk/index.css" />
  <script src="https://cdn.staticfile.org/element-ui/2.13.0/index.js"></script>
  <link rel="stylesheet" href="../../../lib/index.css" />
  <script src="../../../lib/avue.js"></script>
</head>

<body>
  <div id="app">
    <input id="text" v-model="text">
    <input id="text2" v-model="text2">
    <avue-keyboard ref="kb" :ele="ele" :keys="keys" @click="handleKeyboardClick" style="width: 800px; height: 300px">
    </avue-keyboard>
  </div>
</body>

<script>
  new Vue({
    el: '#app',
    data() {
      return {
        keys: [
          ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
          ['a', 'b', 'c', 'd', 'Shift', '清空']
        ],
        text: '',
        text2: '',
        ele: 'text'
      }
    },
    mounted() {
      // 自定义按键绑定click
      this.$refs.kb.bindClick("清空", () => {
        this[this.ele] = ''
      })

      // 模拟更换输入框
      setTimeout(() => {
        this.ele = "text2"
      }, 5000);
    },
    methods: {
      // 键盘点击
      handleKeyboardClick(key, val) {
        this[this.ele] = val
      }
    }
  })
</script>

</html>